﻿using MediatR;
using SlaughterItem.Common.Domains.ListWeek2;
using SlaughterItem.Common.Dtos;
using SlaughterItem.Common.Infrastructures.Interfaces;
using SlaughterItem.Enum;

namespace GetSlaughterItem.API.Application.Commands.Week03.wenk
{
    //制单人
    public class MakeScrentenHandler : IRequestHandler<MakeScrentenCommend, Result>
    {
        private readonly IBaseRepositoryGet<Make> Make;

        public MakeScrentenHandler(IBaseRepositoryGet<Make> Make)
        {
            this.Make = Make;
        }

        public async Task<Result> Handle(MakeScrentenCommend request, CancellationToken cancellationToken)
        {
            var result = new Result() { Code = (int)CommonErrorCode.Search };

            try
            {
                var list = Make.GetAll().ToList();

                if (list != null)
                {
                    result.Code = (int)CommonErrorCode.Success;
                    result.Data = list;
                    result.Msg = "查询成功";
                }
            }
            catch (Exception)
            {

                throw;
            }
            return result;
        }
    
    }
}
